package com.cqhgcloud.monarch.organ.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqhgcloud.monarch.organ.entity.RoleInfo;
import com.cqhgcloud.monarch.organ.service.RoleInfoService;
import com.cqhgcloud.monarch.organ.util.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

/**
 * @param 系统角色表
 * @author weimeilayer@gmail.com
 * @date 2020-01-31 22:33:01
 */
@RestController
@AllArgsConstructor
@Api(value = "系统角色表操作接口")
@RequestMapping("/roleinfo")
public class RoleInfoController {
	
	private RoleInfoService roleInfoService;

	/**
	 * 列表
	 */
	@ApiOperation(value = "分页查询", notes = "分页查询roleInfo 系统角色表")
	@GetMapping("/pagelist")
	public R list(Page page, RoleInfo roleInfo) {
		return R.ok(roleInfoService.queryPage(page, roleInfo));
	}

	/**
	 * 信息
	 */
	@ApiOperation(value = "通过id查询", notes = "通过id查询roleInfo 系统角色表")
	@GetMapping("/info/{roleId}")
	public R info(@PathVariable("roleId") String roleId) {
		return R.ok(roleInfoService.getById(roleId));
	}

	/**
	 * 保存
	 */
	@ApiOperation(value = "保存", notes = "保存系统角色表")
	@PostMapping("/save")
	public R save(@RequestBody RoleInfo roleInfo) {
		return R.ok(roleInfoService.save(roleInfo));
	}

	/**
	 * 修改系统角色表
	 * 
	 * @param roleInfo 系统角色表
	 * @return R
	 */
	@ApiOperation(value = "修改系统角色表", notes = "修改系统角色表")
	@PutMapping("/update")
	public R update(@RequestBody RoleInfo roleInfo) {
		return R.ok(roleInfoService.updateById(roleInfo));
	}

	/**
	 * 删除
	 */
	@ApiOperation(value = "通过id删除系统角色表", notes = "通过id删除系统角色表")
	@DeleteMapping("/delete")
	public R delete(@RequestBody String[] roleIds) {
		return R.ok(roleInfoService.removeByIds(Arrays.asList(roleIds)));
	}
}